<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="${pageContext.request.contextPath}/background/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/background/css/font.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/background/css/xadmin.css">
    <script src="${pageContext.request.contextPath}/background/js/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/background/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/background/js/xadmin.js"></script>
</head>
<body>
<div class="x-body">
    <form id="ggg" class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>公告编号
            </label>
            <div class="layui-input-inline">
                <input type="text" name="msgId" value="${message.msgId}" readonly="readonly" required lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>用户名
            </label>
            <div class="layui-input-inline">
                <input  type="text" readonly="readonly" value="${message.user.username}" name="msgTime" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>发布时间
            </label>
            <div class="layui-input-inline">
                <input  type="text" id="msgTime" readonly="readonly" value="${message.msgTime}" name="msgTime" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>公告标题
            </label>
            <div class="layui-input-inline">
                <input type="text" id="className" readonly="readonly" name="msgTitle" value="${message.msgTitle}" required lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>联系电话
            </label>
            <div class="layui-input-inline">
                <input type="text" name="msgPhone" readonly="readonly" value="${message.msgPhone}" required lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>公告内容
            </label>
            <div class="layui-input-inline">
                <input type="text" name="msgText" readonly="readonly" value="${message.msgText}" required lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <img src="${message.msgImg}" alt="">
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">
            </label>
            <button  type="button" class="layui-btn" onclick="PassMessage(${message.msgId})">
                通过
            </button>
            <button  type="button" class="layui-btn" onclick="NoMessage(${message.msgId})" lay-filter="add" lay-submit="">
                拒绝
            </button>
        </div>
    </form>
</div>
<script type="text/javascript">

    layui.use(['form','layer','jquery'], function(){
        $ = layui.jquery;
        var form = layui.form
            ,layer = layui.layer;
        //监听提交
        window.PassMessage=function(msgId){
            layer.alert('确认要通过审核？',function(index) {
                $ = layui.jquery;
                var layer = layui.layer;
                //监听提交
                $.ajax({
                    type: 'POST',
                    url: 'updateMessagePublishByMsgId',
                    data: {"msgId": msgId},
                    //等待返回值
                    success: function (result) {
                        if (result == "SUCCESS") {
                            layer.alert("已通过审核", {icon: 6}, function () {
                                // 获得frame索引
                                var index = parent.layer.getFrameIndex(window.name);
                                //关闭当前frame
                                parent.layer.close(index);
                                //刷新我的 双亲页面 classobjlist.jsp
                                window.parent.location.reload();
                            });
                        } else {
                            layer.alert(result, {title: "审核失败"});
                        }
                    }
                });
                return false;
            })
        }

        window.NoMessage=function(msgId){
            layer.alert('确认要拒绝申请吗？',function(index) {
                $ = layui.jquery;
                var layer = layui.layer;
                //监听提交
                $.ajax({
                    type: 'POST',
                    url: 'deleteMessageByMsgIdBg',
                    data: {"msgId": msgId},
                    //等待返回值
                    success: function (result) {
                        if (result == "SUCCESS") {
                            layer.alert("拒绝成功", {icon: 6}, function () {
                                // 获得frame索引
                                var index = parent.layer.getFrameIndex(window.name);
                                //关闭当前frame
                                parent.layer.close(index);
                                //刷新我的 双亲页面 classobjlist.jsp
                                window.parent.location.reload();
                            });
                        } else {
                            layer.alert(result, {title: "拒绝失败"});
                        }
                    }
                });
                return false;
            })
        }
    });

</script>
</body>
</html>